package com.xiaoxi.exam.bean.enums;

import cn.xinzhili.xutils.core.ErrorCode;
import cn.xinzhili.xutils.core.FailureException;
import cn.xinzhili.xutils.core.IntCodeEnum;
import com.google.common.collect.Lists;
import lombok.AllArgsConstructor;
import lombok.Getter;

import java.util.ArrayList;
import java.util.List;

@Getter
@AllArgsConstructor
public enum OrderStatus implements IntCodeEnum {
    VERIFY(0, "发送验证码"),
    NEED_PAY(1, "待付款"),
    ORDERING(2, "预约中"),
    ORDER_SUCCESS(3, "预约成功"),
    ORDER_FAILED(4, "预约失败"),
    USER_CANCEL(9, "用户取消"),
    REFUNDED(10, "退款成功");

    private int code;
    private String description;

    public static ArrayList<Short> getShowOrderList() {
        return Lists.newArrayList((short) 2, (short) 3, (short) 4, (short) 9, (short) 10);
    }

    public static OrderStatus getStatus(int code) {
        for (OrderStatus orderStatus : OrderStatus.values()) {
            if (orderStatus.getCode() == code) {
                return orderStatus;
            }
        }
        throw new FailureException(ErrorCode.INVALID_PARAMS);
    }

    public static List<Short> getRefundStatus() {
        return Lists.newArrayList((short) 4, (short) 9);
    }
}
